<template>
  <SModal
      v-model:show="modalShow"
      :title="modalTitle" @positive-click="onSubmit"
  >
    <SForm
        ref="formRef"
        :model="formValue"
    >
      <n-gi :span="12">
        <SFormInput name="username" label="用户名" required v-model:value="formValue.username" @load-rules="loadRules"/>
      </n-gi>
      <n-gi :span="12">
        <SFormInput name="name" label="昵称" required v-model:value="formValue.name" @load-rules="loadRules"/>
      </n-gi>
      <n-gi :span="12">
        <SFormInput name="email" label="邮箱"  v-model:value="formValue.email" @load-rules="loadRules"/>
      </n-gi>
      <n-gi :span="12">
        <SFormInput name="phone" label="手机号"  v-model:value="formValue.phone" @load-rules="loadRules"/>
      </n-gi>
      <n-gi :span="12">
        <SFormNumber name="age" label="年龄" required v-model:value="formValue.age" @load-rules="loadRules"/>
      </n-gi>
    </SForm>
  </SModal>
</template>
<script setup>
import SFormInput from "@/components/public/extForm/SFormInput.vue";
import SForm from "@/components/public/extForm/SForm.vue";
import SFormSelect from "@/components/public/extForm/SFormSelect.vue";
import { querySingerSelect} from "@/api/music/singerApi";
import SModal from "@/components/public/SModal/SModal.vue";
import useSModal from "@/components/public/SModal/useSModal";
import {getUserVo, updateUser} from "@/api/system/userApi";
import SFormNumber from "@/components/public/extForm/SFormNumber.vue";

const api = {
  editApi:updateUser,
  getInfoById:getUserVo
}
const formDefValue = {

}
const {
  onEdit,
  loadRules,
  modalShow,
  modalLoading,
  modalTitle,onSubmit,
  formValue,
  formRef,
} = useSModal("用户",formDefValue,api);

defineExpose({
  onEdit,
  modalLoading
})
const singerList = ref([])
onMounted(()=>{
})
watch(()=>modalShow.value,(value)=>{
  if (value){
    querySingerSelect().then(res=>{
      singerList.value = res.data
    })
  }

})
</script>